<?php


namespace app\common\model;


use think\Model;

class Paper extends Model
{
    protected $autoWriteTimestamp = 'int';
    protected $updateTime = false;

    protected $append = ['journal','college','esi','partition','institute'];

    public function getJournalAttr($value, $data)
    {
        if ($data['journal_id']) {
            $re = PaperJournal::where('id', $data['journal_id'])->value('name');
            return $re;
        }
    }

    public function getCollegeAttr($value, $data)
    {
        if ($data['college_id']) {
            $re = PaperCollege::where('id', $data['college_id'])->value('name');
            return $re;
        }
    }

    public function getEsiAttr($value, $data)
    {
        if ($data['esi_id']) {
            $re = PaperEsi::where('id', $data['esi_id'])->value('name');
            return $re;
        }
    }

    public function getPartitionAttr($value, $data)
    {
        if ($data['partition_id']) {
            $re = PaperPartition::where('id', $data['partition_id'])->value('name');
            return $re;
        }
    }

    public function getInstituteAttr($value, $data)
    {
        if ($data['institute_id']) {
            $re = PaperInstitute::where('id', $data['institute_id'])->value('name');
            return $re;
        }
    }
}